package com.film.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.film.dao.SeatDao;
import com.film.domain.FilmSeat;
import com.film.rowMapper.SeatRowMapper;
import com.film.util.DBUtil;

public class SeatDaoImpl implements SeatDao {
	
	private JdbcTemplate template = new JdbcTemplate(DBUtil.getDataScorse());

	@Override
	public List<FilmSeat> selectSoldSeat(int showingsId) {
		String sql = "select * from film_order t1 " + 
						"inner join film_seat t3 " + 
						"on t1.seat_id = t3.seat_id " + 
						"and t1.showings_id = ?";
		return template.query(sql, new SeatRowMapper(),showingsId);
	}

	@Override
	public List<FilmSeat> selectAllSeat() {
		String sql = "select * from film_seat";
		return template.query(sql, new SeatRowMapper());
	}

}
